package com.xg.demo.observermode;

import java.util.Observable;

/**
 * Created with IntelliJ IDEA.
 *
 * @author hans
 * @version 1.0
 * @date 2023/04/24/14:16
 * @description 观察者模式--定义具体被观察者
 * 目标对象 ConcreteSubject
 * 继承 Observable
 */
public class ConcreteSubject extends Observable {

    private int state;

    public void set(int s) {
        // 目标对象的状态发生了改变
        state = s;
        // 表示目标对象已经做了更改
        setChanged();
        // 通知所有的观察者
        notifyObservers(state);
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }
}
